import about from "../components/About"
import home from "../components/Home"
import news from "../components/News"
import message from "../components/Message"
import user from "../components/User"
import userDetail from "../components/UserDetail"
import test from "../components/Test"
const routes = [
  // {path:"/home/news",component:news},
  {path:"/about",component:about},
  {
    path:"/home",
    component:home,
    children:[
      //子路由的path不能使用"/"开头
      {path:"news",component:news},
      {path:"message",component:message},
      {path:"",redirect:"news"}
    ]
  },
  // 动态路由
  //{path:"/user/:id",component:user},
  {
    path:"/user",
    component:user,
    children:[
      // {path:":id",component:userDetail,props: true },
      // {path:":id",component:userDetail,props: {id:333,name:"zdy",age:19} },
      /*
        箭头函数
        对象解构赋值
        对象的简写形式
        形参的默认参数
      */
      {
        name:"userDetail",
        path:":id",
        component:userDetail,
        props:({params:{id=0},query:{name="xxx",age=18}})=>({
          id, name, age
        })
      },
      {path:"",redirect:"1"}
    ]
  },
  {path:"/test/:id?",component:test,props:true},
  {path:"/",redirect:"/about"}
]

export default routes
